<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+


class LetterTemplate extends AppObj
{
	
	var $properties = array('id'		 	=> NULL,
							'title'	 		=> '',
							'subject'		=> '',
							'body' 			=> '',
							'description'	=> '',
							'from_email'	=> '',
							'from_name'		=> '',
							'to_email'		=> '',
							'to_name'		=> '',
							'to_cc_email'	=> '',
							'to_cc_name'	=> '',
							'to_bcc_email'	=> '',
							'to_bcc_name'	=> '',
							'letter_key'	=> '',
							'skip_field'	=> '',
							'is_html'		=> 0,
							'in_out'		=> 1,
							'predifined'	=> 0,
							'active'		=> 1
							);
	
	
	var $hidden = array('id', 'predifined', 'letter_key', 'is_html', 'skip_field', 'in_out');
	
	
	function validate($values) {
		
		require_once 'eleontev/Validator.php';
		
		$required = array('subject', 'body');
		if(!$values['predifined']) {
			$required[] = 'title';
		}
		
		
		$v =& new Validator($values, false);

		// check for required first, return errors
		$v->requiredArray('required_msg', $required);
		if($v->getErrors()) {
			$this->errors =& $v->getErrors();
			return true;
		}
	}
	
}
?>